<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 每个组件中的值是单独分开的 -->
        <lk-count></lk-count>
        <lk-count></lk-count>
        <lk-count></lk-count>
        <lk-count></lk-count>
        <lk-count></lk-count>
    </div>

     <template id="lk_count">
        <div>
            <p>计数{{count}}</p>
            <button @click="count++">增加</button>
            <button @click="count--">减少</button>
            <p>-------------------</p>
        </div>
    </template>

    <script src="js/vue.js"></script>
    <script>

        const count = {
            data(){
                return {
                    count : 0
                }
            },
            template: `#lk_count`
        };

        // 如果是将 data 设置为 obj 的话，在控制台中会报错
        const app = Vue.createApp({
            // data:{
            //     msg:"测试"
            // },
            data() {
                return {
                    msg: "测试"
                }
            },
            components: {
                "lk-count": count
            }
        }).mount("#app");

    </script>
</body>

</html>